
# Copyright 2009 David Lee Miller
#
# This file is part of POSSM (Python Open Source Scanning Microscopy).
#
# POSSM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# POSSM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License         
# along with POSSM.  If not, see <http://www.gnu.org/licenses/>.
#                                                                           
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

import numpy as n
from client import matplotlib,cm


cmap = {'gray':cm.gray,'pink':cm.pink,'hot':cm.hot,'jet':cm.jet,'summer':cm.summer,'spring':cm.spring,\
	'winter':cm.winter,'autumn':cm.autumn,'flag':cm.flag,'hsv':cm.hsv,'prism':cm.prism,\
	'stern':cm.gist_stern,'rainbow':cm.gist_rainbow,'earth':cm.gist_earth,'ncar':cm.gist_ncar,'cool':cm.cool,\
	'copper':cm.copper,'bone':cm.bone,'rdbu':cm.RdBu}

cmap_r = {'gray':cm.gray_r,'pink':cm.pink_r,'hot':cm.hot_r,'jet':cm.jet_r,'summer':cm.summer_r,'spring':cm.spring_r,\
	'winter':cm.winter_r,'autumn':cm.autumn_r,'flag':cm.flag_r,'hsv':cm.hsv_r,'prism':cm.prism_r,\
	'stern':cm.gist_stern_r,'rainbow':cm.gist_rainbow_r,'earth':cm.gist_earth_r,'ncar':cm.gist_ncar_r,'cool':cm.cool_r,\
	'copper':cm.copper_r,'bone':cm.bone_r,'rdbu':cm.RdBu_r}

######################### Add Custom Cmaps Here ###############################

gatechcmap = {'red':[(0.0,  0.0, 0.0),
		(0.25,  0.0, 0.0),
                 (1.0,  1.0, 1.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.25,  0.0, 0.0),
                 (1.0,  1.0, 1.0)],
         'blue':[(0.0,  0.25, 0.25),
                 (0.25,  1.0, 1.0),
                 (1.0,  0.25, 0.25)]}

gatech=matplotlib.colors.LinearSegmentedColormap('gatech',gatechcmap,1024)

gatechcmap_r = {'red':[(0.0,  1.0, 1.0),   # Define the inverse map
		(0.25,  0.0, 0.0),
                 (1.0,  0.0, 0.0)],
         'green':[(0.0,  1.0, 1.0),
		(0.25,  0.0, 0.0),
                 (1.0,  0.0, 0.0)],
         'blue':[(0.0,  0.25, 0.25),
                 (0.25,  1.0, 1.0),
                 (1.0,  0.25, 0.25)]}

gatech_r=matplotlib.colors.LinearSegmentedColormap('gatech_r',gatechcmap_r,1024)

cmap['gatech']=gatech             # add the cmaps to the dictionaries
cmap_r['gatech'] = gatech_r       #so that they get used in the program

### Define America cmap

grannycmap = {'red':[(0.0,  0.0, 0.0),
		(0.33,  0.0, 0.0),
		(0.67,  1.0, 1.0),
                 (1.0,  1.0, 1.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.33,  0.0, 0.0),
		(0.67,  0.0, 0.0),
                 (1.0,  1.0, 1.0)],
         'blue':[(0.0,  0.0, 0.0),
		(0.33,  1.0, 1.0),
                 (0.67,  0.0, 0.0),
                 (1.0,  1.0, 1.0)]}

granny=matplotlib.colors.LinearSegmentedColormap('granny',grannycmap,1024)

grannycmap_r = {'red':[(0.0,  1.0, 1.0),
		(0.33,  1.0, 1.0),
		(0.67,  0.0, 0.0),
                 (1.0,  0.0, 0.0)],
         'green':[(0.0,  1.0, 1.0),
		(0.33,  0.0, 0.0),
		(0.67,  0.0, 0.0),
                 (1.0,  0.0, 0.0)],
         'blue':[(0.0,  1.0, 1.0),
		(0.33,  0.0, 0.0),
                 (0.67,  1.0, 1.0),
                 (1.0,  0.0, 0.0)]}

granny_r=matplotlib.colors.LinearSegmentedColormap('granny_r',grannycmap_r,1024)

cmap['granny']=granny             # add the cmaps to the dictionaries
cmap_r['granny'] = granny_r       #so that they get used in the program


########### A few custom ones I used for the Nature Physics paper

NatPhysAcmap = {'red':[(0.0,  0.0, 0.0),
		(0.2,  0.0, 0.0),
		(0.5,  0.0, 0.0),
                 (0.75,  1.0, 1.0),
		  (1.0,  1.0, 1.0)],
         'green':[(0.0,  0.0, 0.0),
		 (0.2,  0.2, 0.2),
                 (0.5,  0.85, 0.85),
                 (0.75,  0.95, 0.95),
		  (1.0,  1.0, 1.0)],
         'blue':[(0.0,  0.0, 0.0),
		(0.2,  0.6, 0.6),
		(0.5,  0.0, 0.0),
                 (0.75,  0.25, 0.25),
		  (1.0,  1.0, 1.0)]}

NatPhysA=matplotlib.colors.LinearSegmentedColormap('NatPhysA',NatPhysAcmap,1024)

NatPhysAcmap_r = {'red':[(0.0,  1.0, 1.0),
		(0.25,  1.0, 1.0),
		(0.5,  0.0, 0.0),
                 (0.8,  0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  1.0, 1.0),
		 (0.25,  0.95, 0.95),
                 (0.5,  0.85, 0.85),
                 (0.8,  0.2, 0.2),
		  (1.0,  0.0, 0.0)],
         'blue':[(0.0,  1.0, 1.0),
		(0.25,  0.25, 0.25),
		(0.5,  0.0, 0.0),
                 (0.8,  0.6, 0.6),
		  (1.0,  0.0, 0.0)]}

NatPhysA_r=matplotlib.colors.LinearSegmentedColormap('NatPhysA_r',NatPhysAcmap_r,1024)

cmap['NatPhysA']=NatPhysA
cmap_r['NatPhysA'] = NatPhysA_r


NatPhysBcmap = {'red':[(0.0,  0.0, 0.0),
		(0.15, 0.0, 0.0),
		(0.3,  0.0, 0.0),
		(0.5,  1.0, 1.0),
                 (0.65,  0.9, 0.9),
		  (0.85, 0.3, 0.3),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.15, 0.0, 0.0),
		(0.3,  0.0, 0.0),
		(0.5,  1.0, 1.0),
                 (0.65,  0.9, 0.9),
		  (0.85, 1.0, 1.0),
		  (1.0,  0.5, 0.5)],
         'blue':[(0.0,  0.0, 0.0),
		(0.15, 0.35, 0.35),
		(0.3,  0.75, 0.75),
		(0.5,  1.0, 1.0),
                 (0.65,  0.0, 0.0),
		  (0.85, 0.1, 0.1),
		  (1.0,  0.2, 0.2)]}

NatPhysB=matplotlib.colors.LinearSegmentedColormap('NatPhysB',NatPhysBcmap,1024)

NatPhysBcmap_r = {'red':[(0.0,  0.0, 0.0),
		(0.15, 0.3, 0.3),
		(0.35,  0.9, 0.9),
		(0.5,  1.0, 1.0),
                 (0.7,  0.0, 0.0),
		  (0.85, 0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  0.5, 0.5),
		(0.15, 1.0, 1.0),
		(0.35,  0.9, 0.9),
		(0.5,  1.0, 1.0),
                 (0.7,  0.0, 0.0),
		  (0.85, 0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'blue':[(0.0,  0.2, 0.2),
		(0.15, 0.1, 0.1),
		(0.35,  0.0, 0.0),
		(0.5,  1.0, 1.0),
                 (0.7,  0.75, 0.75),
		  (0.85, 0.35, 0.35),
		  (1.0,  0.0, 0.0)]}

NatPhysB_r=matplotlib.colors.LinearSegmentedColormap('NatPhysB_r',NatPhysBcmap_r,1024)

cmap['NatPhysB']=NatPhysB
cmap_r['NatPhysB'] = NatPhysB_r

BuWGn2cmap = {'red':[(0.0,  0.0, 0.0),
		(0.2, 0.0, 0.0),
		(0.25,  0.0, 0.0),
		(0.32,  1.0, 1.0),
                 (0.55,  0.9, 0.9),
		  (0.75, 0.3, 0.3),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.2, 0.0, 0.0),
		(0.25,  0.0, 0.0),
		(0.32,  1.0, 1.0),
                 (0.55,  0.9, 0.9),
		  (0.75, 1.0, 1.0),
		  (1.0,  0.5, 0.5)],
         'blue':[(0.0,  0.0, 0.0),
		(0.2, 0.35, 0.35),
		(0.25,  0.75, 0.75),
		(0.32,  1.0, 1.0),
                 (0.55,  0.0, 0.0),
		  (0.75, 0.1, 0.1),
		  (1.0,  0.2, 0.2)]}

BuWGn2=matplotlib.colors.LinearSegmentedColormap('BuWGn2',BuWGn2cmap,1024)

BuWGn2cmap_r = {'red':[(0.0,  0.0, 0.0),
		(0.15, 0.3, 0.3),
		(0.35,  0.9, 0.9),
		(0.5,  1.0, 1.0),
                 (0.7,  0.0, 0.0),
		  (0.85, 0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  0.5, 0.5),
		(0.15, 1.0, 1.0),
		(0.35,  0.9, 0.9),
		(0.5,  1.0, 1.0),
                 (0.7,  0.0, 0.0),
		  (0.85, 0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'blue':[(0.0,  0.2, 0.2),
		(0.15, 0.1, 0.1),
		(0.35,  0.0, 0.0),
		(0.5,  1.0, 1.0),
                 (0.7,  0.75, 0.75),
		  (0.85, 0.35, 0.35),
		  (1.0,  0.0, 0.0)]}

BuWGn2_r=matplotlib.colors.LinearSegmentedColormap('BuWGn2_r',BuWGn2cmap_r,1024)

cmap['BuWGn2']=BuWGn2
cmap_r['BuWGn2'] = BuWGn2_r

####### Black-blue-orange ##############


BlkBuOrcmap = {'red':[(0.0,  0.0, 0.0),
		(0.2,  0.0, 0.0),
		(0.4,  0.5, 0.5),
		(0.5,  0.85, 0.85),
		(0.75,  0.9, 0.9),
		(1.0,  1.0, 1.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.2,  0.15, 0.15),
		(0.4,  0.25, 0.25),
		(0.5,  0.45, 0.45),
		(0.75,  0.7, 0.7),
		(1.0,  1.0, 1.0)],
         'blue':[(0.0,  0.0, 0.0),
		(0.2,  0.3, 0.3),
		(0.4,  0.1, 0.1),
		(0.5,  0.0, 0.0),
		(0.75,  0.2, 0.2),
		(1.0,  0.95, 0.95)]}

BlkBuOr=matplotlib.colors.LinearSegmentedColormap('BlkBuOr',BlkBuOrcmap,1024)

BlkBuOrcmap_r = {'red':[(0.0,  1.0, 1.0),
		(0.25, 0.9, 0.9),
		(0.5,  0.85, 0.85),
		(0.6,  0.5, 0.5),
                 (0.8,  0.0, 0.0),
		  (1.0,  0.0, 0.0)],
         'green':[(0.0,  1.0, 1.0),
		(0.25, 0.7, 0.7),
		(0.5,  0.45, 0.45),
		(0.6,  0.25, 0.25),
                 (0.8,  0.15, 0.15),
		  (1.0,  0.0, 0.0)],
         'blue':[(0.0,  0.95, 0.95),
		(0.25, 0.2, 0.2),
		(0.5,  0.0, 0.0),
		(0.6,  0.1, 0.1),
                 (0.8,  0.3, 0.3),
		  (1.0,  0.0, 0.0)]}

BlkBuOr_r=matplotlib.colors.LinearSegmentedColormap('BlkBuOr_r',BlkBuOrcmap_r,1024)

cmap['BlkBuOr']=BlkBuOr
cmap_r['BlkBuOr'] = BlkBuOr_r

#########################################

grayzerocmap = {'red':[(0.0,  0.0, 0.0),
		(0.1, 1.0, 1.0),
		(0.2,  0.2, 0.2),
		(0.3,  1.0, 1.0),
                (0.4,  0.4, 0.4),
		(0.5, 1.0, 1.0),
		(0.6, 0.6, 0.6),
		(0.7,  1.0, 1.0),
		(0.8,  0.8, 0.8),
                (0.9,  1.0, 1.0),
		(1.0,  0.0, 0.0)],
         'green':[(0.0,  0.0, 0.0),
		(0.1, 1.0, 1.0),
		(0.2,  0.2, 0.2),
		(0.3,  1.0, 1.0),
                (0.4,  0.4, 0.4),
		(0.5, 1.0, 1.0),
		(0.6, 0.6, 0.6),
		(0.7,  1.0, 1.0),
		(0.8,  0.8, 0.8),
                (0.9,  1.0, 1.0),
		(1.0,  0.0, 0.0)],
         'blue':[(0.0,  0.0, 0.0),
		(0.1, 1.0, 1.0),
		(0.2,  0.2, 0.2),
		(0.3,  1.0, 1.0),
                (0.4,  0.4, 0.4),
		(0.5, 1.0, 1.0),
		(0.6, 0.6, 0.6),
		(0.7,  1.0, 1.0),
		(0.8,  0.8, 0.8),
                (0.9,  1.0, 1.0),
		(1.0,  0.0, 0.0)]}

grayzero=matplotlib.colors.LinearSegmentedColormap('grayzero',grayzerocmap,1024)

grayzerocmap_r = {'red':[(0.0,  1.0, 1.0),
		(0.1, 0.0, 0.0),
		(0.2,  0.2, 0.2),
		(0.3,  0.0, 0.0),
                (0.4,  0.4, 0.4),
		(0.5, 0.0, 0.0),
		(0.6, 0.6, 0.6),
		(0.7,  0.0, 0.0),
		(0.8,  0.8, 0.8),
                (0.9,  0.0, 0.0),
		(1.0,  1.0, 1.0)],
         'green':[(0.0,  1.0, 1.0),
		(0.1, 0.0, 0.0),
		(0.2,  0.2, 0.2),
		(0.3,  0.0, 0.0),
                (0.4,  0.4, 0.4),
		(0.5, 0.0, 0.0),
		(0.6, 0.6, 0.6),
		(0.7,  0.0, 0.0),
		(0.8,  0.8, 0.8),
                (0.9,  0.0, 0.0),
		(1.0,  1.0, 1.0)],
         'blue':[(0.0,  1.0, 1.0),
		(0.1, 0.0, 0.0),
		(0.2,  0.2, 0.2),
		(0.3,  0.0, 0.0),
                (0.4,  0.4, 0.4),
		(0.5, 0.0, 0.0),
		(0.6, 0.6, 0.6),
		(0.7,  0.0, 0.0),
		(0.8,  0.8, 0.8),
                (0.9,  0.0, 0.0),
		(1.0,  1.0, 1.0)]}

grayzero_r=matplotlib.colors.LinearSegmentedColormap('grayzero_r',grayzerocmap_r,1024)

cmap['grayzero']=grayzero
cmap_r['grayzero'] = grayzero_r